package com.ruoyi.dgdData.service.impl;

import java.util.List;
import java.util.concurrent.Future;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.calculate.BezierCurveUtil;
import com.ruoyi.dgdData.domain.plat.DataDgdKzxsh;
import com.ruoyi.dgdData.domain.plat.DataDgdSd;
import com.ruoyi.dgdData.mapper.DataDgdKzxshMapper;
import com.ruoyi.dgdData.service.IDataDgdKzxshService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;


/**
 * 单轨吊空载向上制动减速度测试Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-12-28
 */
@Service
public class DataDgdKzxshServiceImpl implements IDataDgdKzxshService
{
    @Autowired(required = false)
    private DataDgdKzxshMapper dataDgdKzxshMapper;

    /**
     * 查询单轨吊空载向上制动减速度测试
     * 
     * @param kzxId 单轨吊空载向上制动减速度测试主键
     * @return 单轨吊空载向上制动减速度测试
     */
    @Override
    public DataDgdKzxsh selectDataDgdKzxshByKzxId(Long kzxId)
    {
        return dataDgdKzxshMapper.selectDataDgdKzxshByKzxId(kzxId);
    }

    /**
     * 查询单轨吊空载向上制动减速度测试
     *
     * @param dataTaskId
     * @return 单轨吊空载向上制动减速度测试
     */
    @Override
    public Future<List<DataDgdKzxsh>> selectDataDgdKzxshByDataTaskId(Long dataTaskId) {
        List<DataDgdKzxsh> dataDgdKzxshEntities = dataDgdKzxshMapper.selectDataDgdKzxshByDataTaskId(dataTaskId);
        if (!dataDgdKzxshEntities.isEmpty()) {
            dataDgdKzxshEntities.forEach(item -> {
                if (item.getSuduList() != null) {
                    // 速度曲线数据
                    item.setSdChartLineDTO(BezierCurveUtil.calPoints(item.getSuduList(), 0.1f, false));
                }
            });
        }
        return new AsyncResult<>(dataDgdKzxshEntities);
    }

    /**
     * 查询单轨吊空载向上制动减速度测试列表
     * 
     * @param dataDgdKzxsh 单轨吊空载向上制动减速度测试
     * @return 单轨吊空载向上制动减速度测试
     */
    @Override
    public List<DataDgdKzxsh> selectDataDgdKzxshList(DataDgdKzxsh dataDgdKzxsh)
    {
        return dataDgdKzxshMapper.selectDataDgdKzxshList(dataDgdKzxsh);
    }

    /**
     * 新增单轨吊空载向上制动减速度测试
     * 
     * @param dataDgdKzxsh 单轨吊空载向上制动减速度测试
     * @return 结果
     */
    @Override
    public int insertDataDgdKzxsh(DataDgdKzxsh dataDgdKzxsh)
    {
        dataDgdKzxsh.setCreateTime(DateUtils.getNowDate());
        return dataDgdKzxshMapper.insertDataDgdKzxsh(dataDgdKzxsh);
    }

    /**
     * 批量新增空载向上制动减速度
     *
     * @param dataDgdKzxshes
     */
    @Override
    public int batchDataDgdKzxsh(List<DataDgdKzxsh> dataDgdKzxshes) {
        return dataDgdKzxshMapper.batchDataDgdKzxsh(dataDgdKzxshes);
    }

    /**
     * 修改单轨吊空载向上制动减速度测试
     * 
     * @param dataDgdKzxsh 单轨吊空载向上制动减速度测试
     * @return 结果
     */
    @Override
    public int updateDataDgdKzxsh(DataDgdKzxsh dataDgdKzxsh)
    {
        dataDgdKzxsh.setUpdateTime(DateUtils.getNowDate());
        return dataDgdKzxshMapper.updateDataDgdKzxsh(dataDgdKzxsh);
    }

    /**
     * 变更单轨吊空载向上制动减速度数据状态为2
     *
     * @param kzxId
     * @return 结果
     */
    @Override
    public int updateDataDgdKzxshByKzxId(Long kzxId) {
        return dataDgdKzxshMapper.updateDataDgdKzxshByKzxId(kzxId);
    }

    /**
     * 变更单轨吊空载向上制动减速度数据状态为2
     *
     * @param dataTaskId
     * @return 结果
     */
    @Override
    public int updateDataDgdKzxshByDataTaskId(Long dataTaskId) {
        return dataDgdKzxshMapper.updateDataDgdKzxshByDataTaskId(dataTaskId);
    }

    /**
     * 批量删除单轨吊空载向上制动减速度测试
     * 
     * @param kzxIds 需要删除的单轨吊空载向上制动减速度测试主键
     * @return 结果
     */
    @Override
    public int deleteDataDgdKzxshByKzxIds(Long[] kzxIds)
    {
        return dataDgdKzxshMapper.deleteDataDgdKzxshByKzxIds(kzxIds);
    }

    /**
     * 删除单轨吊空载向上制动减速度测试信息
     * 
     * @param kzxId 单轨吊空载向上制动减速度测试主键
     * @return 结果
     */
    @Override
    public int deleteDataDgdKzxshByKzxId(Long kzxId)
    {
        return dataDgdKzxshMapper.deleteDataDgdKzxshByKzxId(kzxId);
    }
}
